package com.wt.controller;

import com.wt.entity.WqunCommunityBan;
import com.wt.service.WqunCommunityBanService;
import com.wt.service.impl.WqunCommunityBanServiceImpl;
import com.wt.util.R.R;

/**
 * <p>
 * 标签表 前端控制器
 * </p>
 *
 * @author wt
 * @since 2023-09-20
 */
public class WqunCommunityBanController {

    public WqunCommunityBanService wqunCommunityBanService = new WqunCommunityBanServiceImpl();


    //添加禁言
    public R addBan(String id){
        //判断是否已经被禁言了
        int banCount = wqunCommunityBanService.isBan(id);
        if(banCount>=1){
            return R.ok();
        }
        //禁言
        boolean save = wqunCommunityBanService.save(id);
        return save?R.ok().message("禁言成功"):R.error().message("禁言失败");
    }

    //解除禁言
    public R deleteBan(String id){

        WqunCommunityBan byId = wqunCommunityBanService.getIsBan(id);
        if(byId != null){
            byId.setIsBan("0");
            boolean b = wqunCommunityBanService.updateById(byId.getId());
            return b?R.ok().message("解除禁言成功"):R.error().message("解除禁言失败");

        }
        return R.error().message("该用户未被禁言");
    }
}

